<?php namespace App\Http\Controllers;

use App\Http\Models\User;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\View;



class MemberController extends Controller {

	/**
	 * Create a new controller instance.
	 *
	 * @return void
	 */
	public function __construct()
	{

		$this->middleware('CusAuth');
	}

	/**
	 * Show the application dashboard to the user.
	 *
	 * @return Response
	 */
	public function doIndex()
	{
        $title='会员中心';

        if(Request::isMethod('post'))
        {
            $validate = Validator::make(Input::all(),array('CName' => 'required|between:1,20'));

            if ($validate->fails())
            {

                $error = $validate->messages();

                $entry=User::Auth();

                return View::make('member/index', compact('title', 'error','entry'))->with('input', Input::all());
            }
            $user=new User();

            $user->doSave(Input::all());

            $entry=User::Auth();

            return view('member/index', compact('title', 'entry','success'));
        }
        $entry=User::Auth();

		return view('member/index',compact('title','entry'));
	}





}
